package com.aa.dao;

import com.aa.entity.Orderdetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;

@Mapper
public interface OrderdetailDao {

    @Results({
            @Result(column = "gdID",property = "goods",javaType = GoodsDao.class,
                    one = @One(select = "com.aa.dao.GoodsDao.findById"))
    })
    @Select("select * from orderdetail")
    ArrayList<Orderdetail> queryAll();


    @Select("select * from orderdetail where oid = #{oid}")
    @Results({
            @Result(column = "gdID",property = "goods",javaType = GoodsDao.class,
                    one = @One(select = "com.aa.dao.GoodsDao.findById"))
    })
    ArrayList<Orderdetail> query(Integer oid);

    @Delete("delete from orderdetail where odID = #{id}")
    int deleteByID(Integer id);

    @Results({
            @Result(column = "gdID",property = "goods",javaType = GoodsDao.class,
                    one = @One(select = "com.aa.dao.GoodsDao.findById"))
    })
    @Select("select * from orderdetail where odID = #{id}")
    Orderdetail findById(Integer id);


}
